

// 用户名模块相关的中间件   post
//   判断前端参数是否合理  username  password
exports.testLogin = (req , res , next) => {
    // 
    const {username , password} = req.body ;
    if(!username || !password) {
        return next(1) ;
    }
    // 
    next();
}

// 修改密码
exports.testRpwd = (req , res , next) => {
    // 
    const {id , password , newPwd} = req.body ;
    if(!id || !password || !newPwd) {
        return next(1) ;
    }
    // 
    next();
}


exports.testToken = (req , res , next) => {
    // 通过请求头去获取token    authorization用来携带token
    const token = req.headers.authorization ;
    // console.log(token);
    if(!token) {
        return next(2) ;
    }
    // 
    next();
}


exports.testReg = (req , res , next) => {
    // 
    const {username , password} = req.body ;
    if(!username || !password) {
        return next(1) ;
    }
    // 
    next();
}


// 注销
exports.testZhuXiao = (req , res, next) => {
    const {id} = req.body ;
    if(!id) {
        return next(1)
    }
    next()
}
